<template>
  <div class="row">
    <div
      v-for="column in list"
      :key="column.id"
      class="col-4"
      style="width: 18rem;"
    >
      <div class="card h-100 shadow-sm">
        <img :src="column.avatar" :alt="column.title" class="rounded-circle" />
        <div class="card-body">
          <h5 class="card-title">{{ column.title }}</h5>
          <p class="card-text text-left">{{ column.description }}</p>
          <router-link
            :to="`/column/${column.id}`"
            class="btn btn-outline-primary"
            >进入专栏</router-link
          >
        </div>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { defineComponent, PropType } from "vue";
export interface ColumnProps {
  id: number;
  title: string;
  avatar?: string; //可选
  description: string;
}
export default defineComponent({
  name: "ColumnList",
  props: {
    list: {
      type: Array as PropType<ColumnProps[]>, //断言 泛型
      required: true
    }
  },
  setup() {
    return {};
  }
});
</script>

<style scoped></style>
